package com.ruoyi.system.Controller;

import java.util.List;

import com.ruoyi.system.domain.CmManagerInfo;
import com.ruoyi.system.domain.Vo.CmManagerInfoList;
import com.ruoyi.system.service.ICmManagerInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CmManagerWktime;
import com.ruoyi.system.service.ICmManagerWktimeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社管排班管理Controller
 * 
 * @author pop404NotFound
 * @date 2021-11-25
 */
@Controller
@RequestMapping("/CmSystem/Managerwktime")
public class CmManagerWktimeController extends BaseController
{
    private String prefix = "CmSystem/Managerwktime";

    @Autowired
    private ICmManagerWktimeService cmManagerWktimeService;
    @Autowired
    private ICmManagerInfoService cmManagerInfoService;

    @RequiresPermissions("CmSystem:Managerwktime:view")
    @GetMapping()
    public String Managerwktime(ModelMap mmap)
    {
        mmap.put("managerlist",cmManagerInfoService.selectManagerInfoList());
        return prefix + "/Managerwktime";
    }

    /**
     * 查询社管排班管理列表
     */
    @RequiresPermissions("CmSystem:Managerwktime:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CmManagerWktime cmManagerWktime)
    {
        startPage();
        List<CmManagerWktime> list = cmManagerWktimeService.selectCmManagerWktimeList(cmManagerWktime);
        return getDataTable(list);
    }

    /**
     * 导出社管排班管理列表
     */
    @RequiresPermissions("CmSystem:Managerwktime:export")
    @Log(title = "社管排班管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CmManagerWktime cmManagerWktime)
    {
        List<CmManagerWktime> list = cmManagerWktimeService.selectCmManagerWktimeList(cmManagerWktime);
        ExcelUtil<CmManagerWktime> util = new ExcelUtil<CmManagerWktime>(CmManagerWktime.class);
        return util.exportExcel(list, "社管排班管理数据");
    }

    /**
     * 新增社管排班管理
     */
    @GetMapping("/add")
    public String add(ModelMap mmap)
    {
        mmap.put("managerlist",cmManagerInfoService.selectManagerInfoList());
        return prefix + "/add";
    }

    /**
     * 新增保存社管排班管理
     */
    @RequiresPermissions("CmSystem:Managerwktime:add")
    @Log(title = "社管排班管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CmManagerWktime cmManagerWktime)
    {
        return toAjax(cmManagerWktimeService.insertCmManagerWktime(cmManagerWktime));
    }

    /**
     * 修改社管排班管理
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CmManagerWktime cmManagerWktime = cmManagerWktimeService.selectCmManagerWktimeById(id);
        mmap.put("cmManagerWktime", cmManagerWktime);
        mmap.put("managerlist",cmManagerInfoService.selectManagerInfoList());
        return prefix + "/edit";
    }

    /**
     * 修改保存社管排班管理
     */
    @RequiresPermissions("CmSystem:Managerwktime:edit")
    @Log(title = "社管排班管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CmManagerWktime cmManagerWktime)
    {
        return toAjax(cmManagerWktimeService.updateCmManagerWktime(cmManagerWktime));
    }

    /**
     * 删除社管排班管理
     */
    @RequiresPermissions("CmSystem:Managerwktime:remove")
    @Log(title = "社管排班管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(cmManagerWktimeService.deleteCmManagerWktimeByIds(ids));
    }
}
